<?php
// +--------------------------------------------------------------------------
// | ISDCE [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:086-010-57209502>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

namespace Admin\Controller;
use Common\Controller\AdminController;

/**
 * [ 后台控制台 ]
 */
class ConsoleController extends AdminController{
	
	/**
	 * [ 仪表盘 ]
	 */
    public function Dashboard(){
    
		action_log('admin_console_dashboard');//行为记录
		
		common_public()->assign_page('仪表盘');
		
		//获得相关汇总信息
		$this->_getMenu();
		$this->_getNav();
		$this->_getConf();
		$this->_getUser();
		$this->_getGroup();
		$this->_getBehavior();
		$this->_getBehaviorLog();
		$this->_getUpload();
		$this->_getUploadType();
		//$this->_getLog();
		
		$this->display();
		
	}
	
	/**
	 * [ 日历 ]
	 */
    public function Calendar(){
    
		common_public()->assign_page('项目日历');
		
		
		$this->display();
		
	}
	
	/**
	 * [ 菜单汇总 ]
	 */
	public function _getMenu(){
    
		$m_common_menu = M('common_menu');
		
		$menu_num = $m_common_menu->where('status=1')->count();
		
		$this->assign('menu_num', $menu_num);
		
	}
	
	/**
	 * [ 导航汇总 ]
	 */
	public function _getNav(){
    
		$m_common_nav = M('common_nav');
		
		$nav_num = $m_common_nav->where('status=1')->count();
		
		$this->assign('nav_num', $nav_num);
		
	}
	
	/**
	 * [ 配置汇总 ]
	 */
	public function _getConf(){
    
		$m_common_conf = M('common_conf');
		
		$conf_num = $m_common_conf->where('status=1')->count();
		
		$this->assign('conf_num', $conf_num);
		
	}
	
	/**
	 * [ 用户汇总 ]
	 */
	public function _getUser(){
    
		$m_common_user = M('common_user');
		
		$user_num = $m_common_user->where('status=1')->count();
		
		$this->assign('user_num', $user_num);
		
	}
	
	/**
	 * [ 群组汇总 ]
	 */
	public function _getGroup(){
    
		$m_common_user_group = M('common_user_group');
		
		$group_num = $m_common_user_group->where('status=1')->count();
		
		$this->assign('group_num', $group_num);
		
	}
	
	
	/**
	 * [ 行为类型汇总 ]
	 */
	public function _getBehavior(){
    
		$m_common_user_behavior = M('common_user_behavior');
		
		$behavior_num = $m_common_user_behavior->where('status=1')->count();
		
		$this->assign('behavior_num', $behavior_num);
		
	}
	
	/**
	 * [ 行为日志汇总 ]
	 */
	public function _getBehaviorLog(){
    
		$m_common_user_behavior_log = M('common_user_behavior_log');
		
		$behavior_log_num = $m_common_user_behavior_log->where('status=1')->count();
		
		$this->assign('behavior_log_num', $behavior_log_num);
		
	}
	
	/**
	 * [ 上传文件汇总 ]
	 */
	public function _getUpload(){
    
		$m_common_upload = M('common_upload');
		
		$upload_num = $m_common_upload->where('status=1')->count();
		
		$this->assign('upload_num', $upload_num);
		
	}
	
	/**
	 * [ 上传文件类型汇总 ]
	 */
	public function _getUploadType(){
    
		$m_common_upload_type = M('common_upload_type');
		
		$upload_type_num = $m_common_upload_type->where('status=1')->count();
		
		$this->assign('upload_type_num', $upload_type_num);
		
	}
	
	/**
	 * [ 通过API接口获得更新信息 ]
	 */
    public function _getLog(){

		$update_info = S('update_info');
		
		if(!$update_info){
			
			$url  = 'http://api.yiphp.com/log.html';
			$update_info = file_get_contents($url);  

			$update_info = json_decode($update_info,true);
		
			//缓存数据信息2个小时
			S('update_info',$update_info,7200);
	
		}
	
		$this->assign('update_info',$update_info);
	
    }
	
}